<?php
/**
 * Created by xuan.
 * Author: xuan
 * Date: 2018/8/3
 * Time: 18:24
 */

namespace app\api\controller\v1;

use app\api\model\Area as AreaModel;
use think\Exception;
use think\Log;
use think\Request;

class Area
{
    /**
     * 城市区域，省市区三级联动
     *
     *
     */
    public function province()
    {
		$lists = AreaModel::selectProvince();
		if(isset($lists)){
			return json(["returnCode"=>1,"returnMsg"=>"success!","lists"=>$lists]);
		}else{
			return json(["returnCode"=>-2,"returnMsg"=>"fail!","lists"=>""]);
		}
    }
	
	public function city($id)
    {
		if($id){
			$lists = AreaModel::selectCity($id);
			if(isset($lists)){
				return json(["returnCode"=>1,"returnMsg"=>"success!","lists"=>$lists]);
			}else{
				return json(["returnCode"=>-2,"returnMsg"=>"fail!","lists"=>""]);
			}
		}else{
			return json(["returnCode"=>-6,"returnMsg"=>"get参数不能为空!","lists"=>""]);
			
		}
		
		
    }
	
	public function area($id)
    {
		if($id){
			$lists = AreaModel::selectArea($id);
			if(isset($lists)){
				return json(["returnCode"=>1,"returnMsg"=>"success!","lists"=>$lists]);
			}else{
				return json(["returnCode"=>-2,"returnMsg"=>"fail!","lists"=>""]);
			}
		}else{
			return json(["returnCode"=>-6,"returnMsg"=>"get参数不能为空!","lists"=>""]);
			
		}
		
		
    }
}